<template>
  <div>
    <div style="width: 600px;height: 350px;margin:0 auto;box-shadow: 0 2px 12px 0 rgba(0,0,0,0.3);">
      <div style="display: flex;flex-direction: column;">
        <div class="di" style="margin: 25px">
          <span style="margin-right: 20px">旧密码</span>
          <el-input v-model="oldPassword" aria-placeholder="旧密码" style="width: 150px">
          </el-input>
        </div>
        <div class="di" style="margin: 25px">
          <span style="margin-right: 20px">新密码</span>
          <el-input v-model="newPassword" aria-placeholder="新密码" style="width: 150px">
          </el-input>
        </div>
        <div class="di" style="margin: 25px">
          <span style="margin-right: 20px">新密码</span>
          <el-input v-model="newPassword2" aria-placeholder="新密码" style="width: 150px">
          </el-input>
        </div>
        <div class="di">
          <el-button type="success" @click="updatePwd">修改密码</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "UpdatePwd",
  data() {
    return {
      oldPassword: '',
      newPassword: '',
      newPassword2: ''
    }
  }, methods: {
    updatePwd() {
      if (this.oldPassword === "" || this.newPassword === "" || this.newPassword === "") {
        this.messageShow("无法进行更新", "还有内容未填写")
        return;
      }
      if (this.newPassword !== this.newPassword2) {
        this.messageShow("无法进行更新", "一次密码与二次密码输入不相同")
        return;
      }
      let url = "api/user/updateUserPwd/" + this.$store.state.user.userId + "/" + this.oldPassword + "/" + this.newPassword
      this.axios.post(url).then(r => {
        this.messageShow("", r.data.info)
        this.oldPassword = ""
        this.newPassword = ""
        this.newPassword2 = ""
      })
    },
    messageShow(title, message) {
      this.$notify({
        title: title,
        message: (message)
      });
    }
  }
}
</script>

<style scoped>

</style>